//
//  HistoryDeputeTableViewCell.m
//  bitcoin
//
//  Created by  旺链 on 2018/5/28.
//  Copyright © 2018年 比特币. All rights reserved.
//

#import "HistoryDeputeTableViewCell.h"

@implementation HistoryDeputeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)showDetail:(id)sender {
    if (self.showDetail) {
        self.showDetail();
    }
}

-(void)configWidthData:(NSDictionary*)data
{
    self.timeLb.text = data[@"createTime"];
    self.titleLb.text = data[@"currencyRelation"];
    self.typeLb.text = data[@"businessType"];
    self.priceLb.text = data[@"price"];
    //委托数量
    self.numLb.text = data[@"orderAmount"];
    //成交量
    self.volumeLb.text = data[@"tradeAmount"];
    //总成交额
    self.acountLb.text = data[@"totalTransactions"];
    //总手续费
    self.chargeLb.text = data[@"totalPayFee"];
    
    
    NSString *str;
    if ([data[@"appStatus"]integerValue] == 4) {
        //已撤单
        str =data[@"status"];
        self.detailBtn.enabled = NO;
        [self.detailBtn setTitleColor:[UIColor colorWithHexString:@"999999"] forState:UIControlStateNormal];
    }else{
        str = [NSString stringWithFormat:@"%@ >",data[@"status"]];
        self.detailBtn.enabled = YES;
        [self.detailBtn setTitleColor:[UIColor colorWithHexString:@"FFAE1D"] forState:UIControlStateNormal];
    }
    
    [self.detailBtn setTitle:str forState:UIControlStateNormal];
    self.averagePriceLb.text = data[@"avgPrice"];
    
    if ([data[@"businessTypeStatus"]integerValue] == 1) {
        self.typeLb.textColor = [UIColor colorWithHexString:@"#2CB25A"];
    }else{
        
        self.typeLb.textColor = [UIColor colorWithHexString:@"#E1454F"];
    }
    
    NSString *relation =data[@"currencyRelation"];
    NSArray *arr = [relation componentsSeparatedByString:@"/"];
    NSString *trade = arr[0];
    NSString *pay = arr[1];
    
    self.priceTittle.text = [NSString stringWithFormat:@"价格(%@)",pay];
    self.accountTittle.text = [NSString stringWithFormat:@"成交总额(%@)",trade];
    self.averagePriceTittle.text = [NSString stringWithFormat:@"成交均价(%@)",pay];
    self.volumeTittle.text = [NSString stringWithFormat:@"成交量(%@)",trade];
    self.chargeTittle.text = [NSString stringWithFormat:@"总手续费(%@)",trade];
}

@end
